#include("/template/common/layout/_page_layout.html")
#@layout()

#define css()
<style>
    button {
        background: #758ef0;
        color: #FFF;
        border: none;
        border-radius: 15px;
    }
</style>
#end


#define content()
<div class="layui-fluid">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px; color: #009688">
        <legend style="font-size: 20px;font-weight: 500;">管理机构</legend>
    </fieldset>
    <form id="person" class="layui-form" action="">
        <div class="layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label" for="organization"style="width: 180px">组织机构名称</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="organization" name="organization" placeholder="#(organization)"value="#(organization)"
                           class="layui-input " style="width: 500px" disabled/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="management.name" style="width: 180px">管理机构名称</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="management.name" name="management.name" value="#(organization)"
                           class="layui-input " style="width: 500px"required/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.responsibility"style="width: 180px">部门职责</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="management.responsibility" name="management.responsibility"
                           value="#(management.responsibility)" class="layui-input" style="width: 500px" required/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.superior"style="width: 180px">上级部门</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="management.superior" name="management.superior"
                           value="#(management.superior)" class="layui-input"style="width: 500px" required/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.principal"style="width: 180px">上级负责人</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="management.principal" name="management.principal"
                           value="#(management.principal)" class="layui-input"style="width: 500px" required/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.principalcon"style="width: 180px">负责人联系方式</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="tel" id="management.principalcon" name="management.principalcon"
                           value="#(management.principalcon)" class="layui-input"style="width: 500px" lay-verify="required|phone"/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.party"style="width: 180px">党政信息</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="management.party" name="management.party"
                           value="#(management.party)" class="layui-input"style="width: 500px" required/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.manager"style="width: 180px">部门主管姓名</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="management.manager" name="management.manager"
                           value="#(management.manager)" class="layui-input"style="width: 500px" required/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.managercon"style="width: 180px">主管联系方式</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="tel" id="management.managercon" name="management.managercon"
                           value="#(management.managercon)" class="layui-input"style="width: 500px" lay-verify="required|phone"/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.detailedaddr"style="width: 180px">部门详细地址</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="management.detailedaddr" name="management.detailedaddr"
                           value="#(management.detailedaddr)" class="layui-input"style="width: 500px" required/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.num"style="width: 180px">部门人数</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="number" id="management.num" name="management.num"
                           value="#(management.num)" class="layui-input"style="width: 500px" lay-verify="required|length"/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="management.lower"style="width: 180px">下级部门</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="management.lower" name="management.lower"
                           value="#(management.lower)" class="layui-input" style="width: 500px" required/>
                </div>
            </div>

            <div class="layui-form-item layui-hide">
                <label class="layui-form-label" for="source"style="width: 180px">部门资源</label>
                <div class="layui-input-block" style="margin: 0 180px">
                    <input type="text" id="source" name="source"
                           value="#(source)" class="layui-input" style="width: 500px" required/>
                </div>
            </div>

            <!--隐藏flag作为界面是否禁用的方法-->
            <input type="text" id="flag" name="flag"
                   class="layui-input layui-disabled layui-hide" value="#(flag)" required/>
            <input type="text" id="notiId" name="notiId"
                   class="layui-input layui-disabled layui-hide" value="#(notiId)" required/>

            <br>
            <div class="layui-form-item">
                <div class="layui-input-block" style="margin: 0 180px">
                    <button type="button" class="layui-btn" lay-submit lay-filter="pass" id="pass">通过</button>
                    <button type="button" class="layui-btn layui-btn-warm" lay-submit lay-filter="fail" id="fail">不通过</button>
                    <button type="button" class="layui-btn layui-btn-warm" id="back">返回</button>
                </div>
            </div>
        </div>
    </form>
</div>

#end


#define js()
<script type="text/javascript">
    layui.use(['form', 'layer'], function () {
        var layer = layui.layer
            , $ = layui.jquery
            , form = layui.form

        form.verify({
            length: [
                /^[\S]{0,9}$/
                ,'人数不能大于9位'
            ]
        });

        form.on('submit(pass)', function (data) {
            util.sendAjax({
                type: 'POST',
                url: '#(ctxPath)'+$("#source").val()+'Review?verify=2',
                data: $.param(data.field),
                loadFlag: true,
                success: function (data) {
                    history.go(-1);
                },
                error: function (data) {
                    console.log(data);
                }
            });
            return false;
        });

        form.on('submit(fail)', function (data) {
            util.sendAjax({
                type: 'POST',
                url: '#(ctxPath)'+$("#source").val()+'Review?verify=1',
                data: $.param(data.field),
                loadFlag: true,
                success: function (data) {
                    history.go(-1);
                },
                error: function (data) {
                    console.log(data);
                }
            });
            return false;
        });
    });

    if ($('#flag').val() == 2) {
        $("#pass").addClass("layui-disabled");
        $("#pass").attr("disabled", "disabled");
    }else if($('#flag').val() == 1){
        $("#fail").addClass("layui-disabled");
        $("#fail").attr("disabled", "disabled");
    }

    $('#back').click(function () {
        history.go(-1);
    });
    $('#reset').click(function () {
        history.back();
    });
</script>
#end